02. What is a Module?

What is a Module?

ND079 JPND C3 L3 A02 What Is A Module

Modules as Organizational Strategy

Java organizes classes using the concept of Packages. Packages contain classes and class visibility depends on which package references them.

Modules perform a similar role for organizing packages. Each module contains packages, and package visibility depends on which module references them. In the module below, each package contains two classes, and the module com.udacity.jpnd.module contains both packages.

Module `com.udacity.jpnd.module1` Contains Two Packages

Module com.udacity.jpnd.module1 Contains Two Packages

Module Content

A Module is still a JAR. Modules are just like normal jars, in that they contain classes in packages and use a MANIFEST.MF to declare class metadata. They also contain one additional class called a module descriptor. A module descriptor is a special type of Java class that indicates which packages the module makes available, as well as which modules this module relies on.

**Module Descriptor: **A Java class that provides information about the module. It is stored in a class called module-info.java and compiles into a class file called module-info.class.